package stream.part3;

import lombok.extern.slf4j.Slf4j;
import stream.model.Student;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Slf4j
public class Demo01 {
    public static void main(String[] args) {
        List<Student> studentList = new ArrayList<>();
        studentList.add(new Student(1, "张三", "M", 19));
        studentList.add(new Student(1, "李四", "M", 18));
        studentList.add(new Student(1, "王五", "F", 21));
        studentList.add(new Student(1, "赵六", "F", 20)); //条件筛选
        /**
         * 惰性求值 这里是不会输出的
         */
        Stream<Student> studentStream = studentList.stream().filter(student -> {
           log.info("1111111111111");
            return student.getSex().equals("F");
        });
        Stream<Integer> integerStream = studentStream.map(student -> {
            log.info("2222222222222");
            return student.getAge();
        });
        // 这里的会经行输出
        long count = integerStream.count();


    }
}
